<?php
require_once "../funciones.php";
$con = con_caweb();

$page = $_REQUEST['page']; // get the requested page
$limit = $_REQUEST['rows']; // get how many rows we want to have into the grid
$sidx = $_REQUEST['sidx']; // get index row - i.e. user click to sort
$sord = $_REQUEST['sord']; // get the direction
if(!$sidx) $sidx =1;
$nit = $_REQUEST['nit'];

$sql = "select count(item) as count from equiposinconsistentes where nit = '$nit' and descripcion = 'valor alquiler diferentes'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
if( $count >0 ) 
        $total_pages = ceil($count/$limit);
 else 
        $total_pages = 0;

if ($page > $total_pages) $page=$total_pages;
        $start = $limit*$page - $limit; // do not put $limit*($page - 1)
if ($start<0) $start = 0;

$sql = "select * from equiposinconsistentes where nit = '$nit' and descripcion = 'valor alquiler diferentes' ORDER BY $sidx $sord LIMIT $start , $limit";
$result = mysql_query($sql);


if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) {
    header("Content-type: application/xhtml+xml;charset=utf-8");
} else {
    header("Content-type: text/xml;charset=utf-8");
}
$et = ">";
echo "<?xml version='1.0' encoding='utf-8'?$et\n";
echo "<rows>";
echo "<page>".$page."</page>";
echo "<total>".$total_pages."</total>";
//echo "<total>".$sql."</total>";
echo "<records>".$count."</records>"; // be sure to put text data in CDATA
while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
    echo "<row id='".$row['id']."'>";
    $sql = "select name from mantis_project_table where nit = '$nit'";
    $con = con_mantis();
    $tmp = mysql_query($sql);
    $tmp = mysql_fetch_array($tmp);
    echo "<cell>". strtoupper($tmp['name'])."</cell>";
    echo "<cell>". strtoupper($row['interno'])."</cell>";
    echo "<cell>". strtoupper($row['item'])."</cell>";
    echo "<cell>". strtoupper($row['tarifaFac'])."</cell>";
    echo "<cell>". strtoupper($row['tarifaSer'])."</cell>";
    echo "</row>";
}
echo "</rows>";
?>